//
//  MSKeyBoardTool.h
//  PeopleForTheFirstMall
//
//  Created by mac on 2021/5/31.
//  Copyright © 2021 MS. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@protocol MSKeyBoardToolDelegate;
@interface MSKeyBoardTool : NSObject

@property (nonatomic, weak) id<MSKeyBoardToolDelegate> delegate;
@property(nonatomic,strong) NSArray *fieldArray;    ///< 用于光标切换的数组，不设置将不可切换
@property(nonatomic,strong) UIToolbar *toolBar;

/** 键盘遮挡自动上移（注：键盘弹出前调用，如textFieldDidBeginEditing:代理方法） */
- (void)ms_autoMoveTextFieldUp:(id)textField
                 animationView:(nullable UIView *)animationView
                   showToolBar:(BOOL)showToolBar;

@end

@protocol MSKeyBoardToolDelegate <NSObject>

/** 完成 */
- (void)ms_textFieldShouldReturn:(UITextField *)textField;

@end


#pragma mark - 宏
/// property
#define ms_keyBoardTool @property(nonatomic,strong) MSKeyBoardTool *keyBoardTool;
/// getting
#define ms_lazyLoadingGetKeyBoardToolAndSetDelegate \
- (MSKeyBoardTool *)keyBoardTool\
{\
    if (!_keyBoardTool)\
    {\
        _keyBoardTool = [[MSKeyBoardTool alloc] init];\
        _keyBoardTool.delegate = self;\
    }\
    return _keyBoardTool;\
}
/// getting
#define ms_lazyLoadingGetKeyBoardTool \
- (MSKeyBoardTool *)keyBoardTool\
{\
    if (!_keyBoardTool)\
    {\
        _keyBoardTool = [[MSKeyBoardTool alloc] init];\
    }\
    return _keyBoardTool;\
}
/// 键盘遮挡自动上移
#define AUTO_MOVE_TEXTFIELD_UP(textField, superView, showInputAccessoryView) [self.keyBoardTool ms_autoMoveTextFieldUp:textField animationView:superView showToolBar:showInputAccessoryView];

NS_ASSUME_NONNULL_END
